package team.lourd.network.system.own.controller.netel;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import team.lourd.network.system.own.message.Result;
import team.lourd.network.system.own.service.TestNEModelService;

/**
 * 测试网元模型 - controller类
 *
 * @author JADemo
 * @date 2019/2/27 19:53
 */
@RestController
@RequestMapping(value = "/pm-models")
public class TestNEModelManagerController {
    @Autowired
    private TestNEModelService testNEModelService;

    // 逐步运行API
    @RequestMapping("/api/step/run")
    public Result stepRun(@RequestParam("command") String command, @RequestParam("jsonStr") String jsonStr) {
        Result result = new Result();
        try {
            result.setBody(testNEModelService.stepRun(command, jsonStr));
            result.setState(0);
        } catch (Exception e) {
            e.printStackTrace();
            result.setState(-1);
        }
        return result;
    }

    // 逐步判断条件
    @RequestMapping("/api/step/judge")
    public boolean stepJudge(@RequestParam("condition") String condition, @RequestParam("jsonStr") String jsonStr) {
        try{
            return testNEModelService.stepJudge(condition, jsonStr);
        }
        catch(Exception e){
            e.printStackTrace();
            return false;
        }
    }
}
